package com.lyc.yuki.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.lyc.yuki.serializer.CustomTimestampDeserializer;
import com.lyc.yuki.serializer.CustomTimestampSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.sql.Timestamp;

/**
 * @Author: lyc
 * @Date: 2025/7/24 22:49
 */
@Configuration
public class JacksonConfig {

    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        SimpleModule simpleModule = new SimpleModule();
        simpleModule.addSerializer(Timestamp.class, new CustomTimestampSerializer());
        simpleModule.addDeserializer(Timestamp.class, new CustomTimestampDeserializer());
        objectMapper.registerModule(simpleModule);
        return objectMapper;
    }
}
